<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "bus_health_custom".
 *
 * @property string $id
 * @property string $member_id
 * @property string $health_id
 * @property string $health_name
 */
class BusHealthCustom extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'bus_health_custom';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['member_id', 'health_id', 'health_name'], 'required'],
            [['member_id', 'health_id'], 'integer'],
            [['health_name'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'member_id' => '会员id',
            'health_id' => '体质id',
            'health_name' => '自定义体质名称',
        ];
    }

    /**
     * 获取自定义体质的信息
     * @param int $member_id 会员id
     * @param int $health_id 其他选项的体质id
     * @return string 自定义的体质名称
     */
    public static function getHealthName($member_id, $health_id)
    {
        return self::findOne(['member_id' => $member_id, 'health_id' => $health_id])->health_name;
    }
}
